# 元组中数据不可变，其他几乎和列表一致
def use_tuple():
    info_tuple = ('小明',15,17.85,'小明')

    for i in info_tuple:
        print(i)

    print('-'*50)
    print(info_tuple.index('小明'))

    print('-'*50)
    print(info_tuple.count('小明'))


def use_str():
    """
    格式化字符串
    :return:
    """
    info_tuple = ('小明', 15, 17.85)
    print("姓名是%s,年龄%d,身高%.2fm" %info_tuple)
    print('-'*50)
    info_str = "姓名是%s,年龄%d,身高%.2fm" %info_tuple
    print(info_str)


def use_tuple_error():
    # 定义一个列表
    a = [1]
    print(type(a))

    # 定义一个元素的元组,错误示范：会变成int型
    b = (1)
    print(type(b))

    # 正确方式
    b = (1,)
    print(type(b))

if __name__ == '__main__':
    # use_tuple()
    # use_str()
    use_tuple_error()